/**
 * Created by zhangqingxi on 2017-03-31.
 */


/**
 * 加载表格
 *
 */
var disposeModelPath=ROOT_PATH+'/environmental/solidWaste/dispose/';

$(function () {

    var url=disposeModelPath+'findByParam.shtml';
    loadDataList(url);
    //高级查询
    initAdvancedSearch();

    //查询按钮事件
    initSearchClick();

    //重置参数
    initResetClick();

    //处理按钮事件
    $('#btn_solidWaste_apply_dispose').on('click',function () {

        var checkedRows=$('#dataList').datagrid('getChecked');
        if(checkedRows.length == 0){
            layer.alert("选择需要处理的行！");
            return
        }
        var id=checkedRows[0].id;

        openLayer("固废处理",disposeModelPath+"dispose.shtml?id="+id);

    });

});
/**
 * 加载表格
 *
 */
function  loadDataList(url) {

    $('#dataList').datagrid({
        url:url,
        queryParams:{
            sort:'d.addTime',
            order:'desc'
        },
        // idField:'id',
        fitColumns:true,
        pagination:true,
        rownumbers:true,
        singleSelect:true,
        sortOrder:true,
        striped:true,
        fit:true,
        columns:[[
            {field:'id',width:10,checkbox:true},
            {field:'solidWasteName',title:'固废名称',width:10,formatter:function (value,row,index) {
                return '<a href="javascript:void(0)" onclick="showDetails(\''+row.id+'\')" style="color: blue">'+value+'</a>'

            }},
            {field:'solidWasteTypeName',title:'固废类别',width:10},
            {field:'hazardousWasteCode',title:'危废代码',width:10},
            {field:'vulgo',title:'俗称',width:10},
            {field:'estimatedProduction',title:'预估产生量(吨)',width:10},
            {field:'actualProduction',title:'实际产生量(吨)',width:10},
            {field:'addUserName',title:'登记人',width:10},
            {field:'addDeptName',title:'登记部门',width:10},
            {field:'d.addTime',title:'登记时间',width:10,sortable:true,formatter:function (value,row,index) {
                return row.addTime;
            }},
            {field:'remarks',title:'备注',width:10}
        ]],
        toolbar: '#toolbar'

    });


}

function showDetails(id) {

    openLayer("固废申请处理详情",disposeModelPath+"details.shtml?id="+id);

}